package com.songlanyun.common.utils;

import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.util.List;
import java.util.Map;

public class PageMUtil {
    public static IPage paging(IPage page, Map<String, Object> params, List list) {
        Integer current = MapUtil.getInt(params, "page");
        Integer curr = current == null ? 1 : current;
        Integer limit = MapUtil.getInt(params, "limit");
        Integer size = limit == null ? 10 : limit;
        page.setRecords(list);
        page.setTotal(list.size());
        page.setCurrent(curr);
        page.setSize(size);
        return page;
    }
}
